package cn.com.haopy.yue.ai.db.service.hos.impl;


import cn.com.haopy.yue.ai.db.entity.arisk.AIRiskStandardCategory;
import cn.com.haopy.yue.ai.db.mapper.arisk.AIRiskStandardCategoryMapper;
import cn.com.haopy.yue.ai.db.service.BaseServiceImpl;
import cn.com.haopy.yue.ai.db.service.hos.AIRiskStandardCategoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * @Description: TODO
 * @Author DuTao
 * @Date 2023/9/25 14:49
 */
@Service
@Slf4j
public class AIRiskStandardCategoryServiceImpl extends BaseServiceImpl<AIRiskStandardCategoryMapper, AIRiskStandardCategory> implements AIRiskStandardCategoryService {

    @Override
    public List<AIRiskStandardCategory> getCategory(Integer chargeId, Integer pId) {
        QueryWrapper<AIRiskStandardCategory> queryWrapper = new QueryWrapper<>();
        if (Objects.nonNull(chargeId)) {
            queryWrapper.lambda().eq(AIRiskStandardCategory::getChargeId, chargeId);
        }

        if (Objects.nonNull(pId)) {
            queryWrapper.lambda().eq(AIRiskStandardCategory::getPid, pId);
        }
        queryWrapper.lambda().orderByAsc(AIRiskStandardCategory::getSortIndex);

        return list(queryWrapper);
    }
}
